package com.future.hedongjun.mall.adapter;

import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseSectionQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.entity.SectionEntity;
import com.future.baselib.utils.FlowLayoutManager;
import com.future.hedongjun.R;
import com.future.hedongjun.mall.bean.GoodsTypeSection;

import java.util.List;

/**
 * @author jniu
 * @Email niuxiaoqi@hztianque.com
 * @time 2018/12/12
 */
public class GoodsTypeAdapter extends BaseQuickAdapter<GoodsTypeSection, GoodsTypeAdapter.GoodsTypeViewHolder> {

    public int selectPosition = -1;

    public GoodsTypeAdapter( @Nullable List<GoodsTypeSection> data) {
        super(R.layout.recycler_item_goods_type_head, data);
    }


    @Override
    public void setNewData(@Nullable List<GoodsTypeSection> data) {
        super.setNewData(data);
        selectPosition = -1;
    }

    @Override
    protected void convert(GoodsTypeAdapter.GoodsTypeViewHolder helper, GoodsTypeSection item) {

        helper.tvTitle.setText(item.title);
//        helper.recyclerView

//        helper.setBackgroundRes(R.id.tv_title, R.drawable.recycler_item_goods_type_unselect_bg);
//        if (selectPosition == helper.getAdapterPosition()) {
//            helper.setBackgroundRes(R.id.tv_title, R.drawable.recycler_item_goods_type_select_bg);
//        }
//        helper.setText(R.id.tv_title,item.t.getTitle());
    }

    public static class GoodsTypeViewHolder extends BaseViewHolder{

        public TextView tvTitle;
        public RecyclerView recyclerView;

        public GoodsTypeViewHolder(View view) {
            super(view);
            tvTitle = view.findViewById(R.id.tv_title);
            recyclerView = view.findViewById(R.id.recyclerView);
            recyclerView.setLayoutManager(new FlowLayoutManager());
//            recyclerView.setAdapter();
        }
    }
}
